import {jsonp} from "@/common/js/jsonp";
import {options} from "@/config/api-config/config";

export async function getRank() {
    const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg'
    const data = {
        g_tk: 1928093487,
        inCharset: 'utf-8',
        outCharset: 'utf-8',
        notice: 0,
        format: 'jsonp',
        uin: 0,
        needNewCode: 1,
        platform: 'h5'
    }
   let ret = await jsonp(url,data,options)
   return ret.data.topList
}

export function rankSong_format(list) {
   return list.map(item => {
        let info = {
            musicData: {}
        }
        info.musicData.songid = item.data.songid
        info.musicData.songmid = item.data.songmid
        info.musicData.songname = item.data.songname
        info.musicData.albumname = item.data.albumname
        info.musicData.albummid = item.data.albummid
        info.musicData.interval = item .data.interval
        info.musicData.url = item.data.url
        info.musicData.singer = item.data.singer
        info.musicData.pay = item.data.pay
        return info
    })
}
